package com.dayuanit.dy17.spring.config;

import com.dayuanit.dy17.spring.entity.Dog;
import com.dayuanit.dy17.spring.entity.Person;
import org.springframework.context.annotation.Bean;

/**
 * javaConfig的方式创建对象
 */
public class LibraryConfig {

    @Bean
    public Dog dog() {
        Dog dog = new Dog();
        dog.setColor("白色");
        dog.setName("旺财007");
        dog.setPrice(800);
        return dog;
    }

    @Bean
    public Person person(Dog dog) {
        Person person = new Person();
        person.setAge(20);
        person.setUsername("tom");
        person.setDog(dog);
        return person;
    }

}
